<?php
	session_start();
	require 'libraries/CostLib.php';
	require 'libraries/UserLibrary.php';
	
	isSessionSet("administrator", null, "index.php");
?>

<html>
	<head>
		<title>CASLIMS | Edit Analysis Cost</title>
		<script type="text/javascript" src="scripts/validateCost.js"></script>
		<link rel="stylesheet" type="text/css" href="scripts/page.css" />
		<link href="tools/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
	</head>
	<body>
		<div id="header"></div>
		<div id="wrapper">
			<div id="pagetop">
				<div class="greeting">Hi, <?php echo $_SESSION["administrator"];?> | <a href="Logout.php">Log out</a> | <a href="AdministratorHomepage.php"> Home </a></div>
				<div class="homepage"><?php echo $_SESSION["administrator"];?></div>
			</div>
			<form name="editCost" action="ProcessEditCost.php" method="post"  onsubmit = 'return checkCostFields(<?php echo '"'.$_GET["sample_type"].'"';?>)' >					
				<table border='0'>
					<thead>
						<tr>
							<th>ANALYSIS CATEGORY</th>
							<th>ANALYSIS COMPONENT</th>
							<th>PREVIOUS COST</th>
							<th>NEW COST</th>
						</tr>
					</thead>
					<?php 
					$con = mysql_connect('localhost','login','login') or die('Could not connect: ' . mysql_error());
					mysql_select_db('casl') or die(mysql_error());
				
					$result = mysql_query("SELECT main_type, sample_type, analysis_type, cost FROM cost_analysis WHERE sample_type = '".$_GET["sample_type"]."'");
					while($entry = mysql_fetch_array($result)){
					?>			
						<tr>
							<td><b><?php echo "$entry[1]";?></b></td>
							<td><?php echo "$entry[2]";?></td>
							<td><?php echo "$entry[3]";?></td>
							<td><input type="text" name='<?php echo str_replace(".","_",str_replace(" ","_",$entry[2]));?>'  onKeyUp="validDecimal(this)" value ="<?php echo "$entry[3]";?>"id="<?php echo "$entry[2]";?> Cost"/></td>
						</tr>	
					
					<?php
					}						
					mysql_close($con);
					?>					
				</table>				
				<div id="buttons">
					<input name="cost" id="cost" type="reset" value="Clear" />
					<input type="submit" name="cost" id="cost" value="Submit"/>
					<input type="button" value="Back To View Tree" onClick='document.location.href = "ViewAnalysisCosts.php"'>
				</div>	
				<br/>
			</form>	
			<div id="footerwrap">
				<div id="footer"> 
					<div class="copyright">Copyright 2011.<a>CASL BIOTECH-UPLB.</a> All Rights Reserved.<br/> 
				Arianne Buse&ntilde;os | Darlene Joy Masong | Rick Jason Obrero | Jonathan Pandi | Jonathan Simbahan | Emmanuel Soriano 
					</div>  
	    	    </div>
			</div>				
		</div>				
	</body>
</html>